define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'askcase/index' + location.search,
                    add_url: 'askcase/add',
                    edit_url: 'askcase/edit',
                    del_url: 'askcase/del',
                    multi_url: 'askcase/multi',
                    import_url: 'askcase/import',
                    table: 'askcase',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'fa_case_id',
                sortName: 'fa_case_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'fa_case_id', title: __('Fa_case_id')},
                        {field: 'fa_case_uuid', title: __('Fa_case_uuid'), operate: 'LIKE'},
                        {field: 'fa_case_code6', title: __('Fa_case_code6')},
                        {field: 'fa_case_openid', title: __('Fa_case_openid'), operate: 'LIKE'},
                        {field: 'fa_case_phone', title: __('Fa_case_phone'), operate: 'LIKE'},
                        {field: 'fa_case_uname', title: __('Fa_case_uname'), operate: 'LIKE'},
                        {field: 'fa_case_uage', title: __('Fa_case_uage')},
                        {field: 'fa_case_usex', title: __('Fa_case_usex')},
                        {field: 'fa_case_remark', title: __('Fa_case_remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'fa_case_channelid', title: __('Fa_case_channelid')},
                        {field: 'fa_case_frontpoint', title: __('Fa_case_frontpoint')},
                        {field: 'fa_case_backpoint', title: __('Fa_case_backpoint')},
                        {field: 'fa_case_imagebefore', title: __('Fa_case_imagebefore'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'fa_case_imageafter', title: __('Fa_case_imageafter'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'fa_case_createtime', title: __('Fa_case_createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'fa_case_updatetime', title: __('Fa_case_updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'fa_case_channeluuid', title: __('Fa_case_channeluuid'), operate: 'LIKE'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
